/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package org.swirrel.listener;

import java.awt.event.FocusEvent;
import java.awt.event.FocusListener;

import org.swirrel.util.MethodCall;
import org.swirrel.util.SwirrelException;

/**
 *
 * @author Gronau
 */
public class SwirrelFocusListener extends AbstractSwirrelListener implements FocusListener{
    private final MethodCall focusGainedCall;
    private final MethodCall focusLostCall;

    public SwirrelFocusListener(
            MethodCall focusGainedCall,
            MethodCall focusLostCall) {
        this.focusGainedCall = focusGainedCall;
        this.focusLostCall = focusLostCall;
        if (!checkSignature(focusGainedCall, FocusEvent.class) ||
            !checkSignature(focusLostCall, FocusEvent.class)) {
            throw new SwirrelException("Method must have none or one FocusEvent argument");
        }
    }

    public void focusGained(FocusEvent e) {
       call(focusGainedCall, e);
    }

    public void focusLost(FocusEvent e) {
       call(focusLostCall, e);
    }
}
